// pages/appLetWork/work1/work1.js
Page({
  data: {
    active: 0,
    list: [
      { Isbtn: true, letter: "c", src: 'http://img.lyxalyh.top/c.png', Letter: "C" },
      { Isbtn: false, letter: "d", src: 'http://img.lyxalyh.top/d.png', Letter: "D" },
      { Isbtn: false, letter: "e", src: 'http://img.lyxalyh.top/e.png', Letter: "E" },
      { Isbtn: false, letter: "f", src: 'http://img.lyxalyh.top/f.png', Letter: "F" },
      { Isbtn: false, letter: "g", src: 'http://img.lyxalyh.top/g.png', Letter: "G" },
      { Isbtn: false, letter: "a", src: 'http://img.lyxalyh.top/a.png', Letter: "A" },
      { Isbtn: false, letter: "b", src: 'http://img.lyxalyh.top/b.png', Letter: "B" },
    ],
    src: 'http://img.lyxalyh.top/c.png'
  },
  onClickLeft() {
    wx.navigateBack({
      tail: 1
    })
  },
  /*bt(e) {
    var bbtn = this.data.bbtn;
    for (var i = 0; i < bbtn.length; i++) {
      var Isbtn = 'bbtn[' + i + '].Isbtn';
      if (e.currentTarget.dataset.isbtn == bbtn[i].letter) {
        this.setData({
          [Isbtn]: true,
          src: bbtn[i].src
        })
      } else {
        this.setData({
          [Isbtn]: false
        })
      }
    }
  },*/

  /**
  *简化后的代码 
   */
  bt(e){
    let num =e.currentTarget.dataset.index;
    let list =this.data.list; 
    list.forEach(v=>{
      v.Isbtn =false
    })
    list[num].Isbtn =true
    let src ='http://img.lyxalyh.top/'+list[num].Letter.toLowerCase()+'.png'
    this.setData({
      list,
      src
    })
  },
})